package com.atguigu.yygh.hosp.controller;

import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.hosp.service.HospitalService;
import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @ClassName HospitalController
 * @Description: 类描述
 * @Author: admin
 * @CreateDate: 2024/6/9 11:39
 * @UpdateUser: 更新人
 * @UpdateDate: 2024/6/9 11:39
 * @UpdateRemark: 更新的信息
 * @Version: 1.0
 */

@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin //解决跨域问题
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    /**
     * 获取医院列表
     * @param page
     * @param limit
     * @param hospitalQueryVo 条件查询
     * @return
     */
    @GetMapping("list/{page}/{limit}")
    public Result listHosp(@PathVariable("page") Integer page,
                           @PathVariable("limit") Integer limit,
                           HospitalQueryVo hospitalQueryVo){
        Page<Hospital> pageModel =hospitalService.selectHospPage(page, limit, hospitalQueryVo);
        return Result.ok(pageModel);
    }

    /**
     * 修改医院状态
     * @param id
     * @param status
     * @return
     */
    @ApiOperation(value = "更新医院状态")
    @GetMapping("updateHospStatus/{id}/{status}")
    public Result updateStatus(@PathVariable("id") String id, @PathVariable("status") Integer status){
        hospitalService.updateStatus(id, status);
        return Result.ok();
    }

    @ApiOperation(value = "医院详情信息")
    @GetMapping("showHospDetail/{id}")
    public Result showHospDetail(@PathVariable("id") String id){
        Map<String, Object> result=hospitalService.getHospitalById(id);
        return Result.ok(result);
    }

}
